home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
apps
/
102
/
examples
/
textalgn.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-01-25
|
5KB
|
128 lines
/* Programmer's guide to GEM - 1986 - p.158 -listing 3.2 - CJPurcell Dec'86 */
/* CTRLRC.C - MAIN DRIVER for draw_rc() examples using Mark Williams C */
/* to be tested in NDC and/or RC mode with or without GDOS for implications */
#include <portab.h> /* try <> and see ?? */
#include <osbind.h> /* system constants */
#include <gemdefs.h> /* GEM-definition */
/* #include <obdefs.h> / * object definition*/
WORD contrl[12], intin[128], ptsin[128], intout[128], ptsout[128];
#define M_OFF 256
#define RC_COORDS 2
#define RIGHT_ALIGNED 2
#define BOTTOM_ALIGNED 3
VOID main() /* not GEMAIN as in ref. */
{
WORD handle, work_in[11], work_out[57], max_w, max_h;
WORD ii;
appl_init(); /* init AES for call */
handle = graf_handle( &ii,&ii,&ii,&ii ); /* get screen handle */
graf_mouse( M_OFF, NULL ); /* hide mouse */
v_clrwk( handle ); /* clear workstation */
for( ii=0; ii<11; ++ii ) work_in[ii]=1; /* init work_in array*/
work_in[10] = RC_COORDS; /* using RC coordinates */
v_opnvwk( work_in, &handle, work_out ); /* open the workstation */
max_w = work_out[0]; max_h = work_out[1];
draw_rc( handle,0,0,max_w,max_h ); /* do the examp.routine */
vst_alignment( handle,RIGHT_ALIGNED,BOTTOM_ALIGNED,&ii,&ii );
v_gtext( handle,max_w,max_h,"Press any Key to Continue" );
evnt_keybd(); /* pause for viewing */
v_clsvwk( handle ); /* close workstation */
appl_exit(); /* tell AES finished */
}
/* Programmer's Guide to GEM - 1986 - p.199,Listing 3.13 - CJPurcell- Dec'86 */
/* TEXTALGN.C - Display Text Alignment example Effects on GEM-GDOS - */
/* #include <portab.h> */
BYTE *x_labels[3] = { " 0:left "," 1:center "," 2:right " };
BYTE *y_labels[6] = { " 0:baseline "," 1:half line "," 2:ascent line ",
" 3:bottom ", " 4:descent ", " 5:top " };
#define LEFT 0
#define CENTER 1
#define HALF 1
#define TOP 5
#define PATTERN 2
#define LIGHT_DITHER_PATTERN 1
#define BLACK 1
#define BIG_LETTERS 36
#define COLOR_LETTERS 18
#define SMALL_LETTERS 10
VOID draw_rc( handle, dx, dy, swidth, sheight )
WORD handle, dx, dy, swidth, sheight;
{
WORD pxy[4], junk, cur_x, cur_y, incr_x, incr_y, start_x, resize;
WORD hor_in, ver_in;
WORD y_lines[6]; /* table of row positions */
resize = COLOR_LETTERS ; /* presume color system, but*/
if ( 2 == Getrez() ) resize = BIG_LETTERS ;
/* set screen to background dither pattern to highlight text */
pxy[0] = dx ;
pxy[1] = dy ;
pxy[2] = dx + swidth ;
pxy[3] = dy + sheight ;
vsf_interior( handle, PATTERN );
vsf_style ( handle, LIGHT_DITHER_PATTERN );
vsf_color ( handle, BLACK );
v_bar( handle, pxy );
incr_x = swidth / 3 ;
start_x = dx + ( 2* incr_x) / 3 ;
incr_y = sheight / 7 ;
/* set up row positions to make row display more pleasing */
for(cur_y=dy+incr_y, ver_in = 0; ver_in < 6; ++ver_in, cur_y += incr_y)
y_lines[ver_in] = cur_y;
y_lines[1] -= incr_y / 3 ; /* move these up to make some room */
y_lines[2] -= incr_y / 3 ;
y_lines[3] += incr_y / 2 ; /* and move these down */
y_lines[4] += incr_y / 2 ;
/* display text in different alignments */
vst_point( handle, resize, &junk, &junk, &junk, &junk );
for(cur_x=dx+start_x,hor_in = 0; hor_in < 3; ++hor_in, cur_x += incr_x)
for( ver_in = 0 ; ver_in < 6 ; ++ver_in )
{
vst_alignment( handle, hor_in, ver_in, &junk, &junk );
v_gtext( handle, cur_x , y_lines[ver_in], " ALIGN " );
}
/* draw alignment grid and label everything */
vst_point( handle,SMALL_LETTERS, &junk, &junk, &junk, &junk );
/* draw and label vertical alignment lines */
vst_alignment( handle, CENTER , TOP , &junk, &junk );
for(cur_x=dx+start_x,hor_in = 0; hor_in < 3; ++hor_in, cur_x += incr_x)
{
pxy[0] = pxy[2] = cur_x ;
pxy[1] = dy ;
pxy[3] = dy + sheight ;
v_pline( handle, 2, pxy );
v_gtext( handle, cur_x, dy, x_labels[hor_in] ); /* label columns */
}
/* draw and label horizontal alignment lines */
vst_alignment( handle, LEFT , HALF , &junk, &junk );
for( ver_in = 0 ; ver_in < 6 ; ++ver_in )
{
pxy[1] = pxy[3] = y_lines[ver_in];
pxy[0] = dx ;
pxy[2] = dx + swidth ;
v_pline( handle, 2, pxy );
v_gtext(handle,dx,y_lines[ver_in], y_labels[ver_in]);/*label rows*/
}
} /* CJPurcell 17Jan'87 */